<template>
	<view class="content">
		<image class="logo" :src="buildInfo.thumb" mode="aspectFill"></image>

		<view class="header-content">
			<view class="header-left">
				<view class="line"></view>
				<text class="header-title">基本信息</text>
			</view>
			<image class="header-content-share" src="../../static/images/share_icon.png"></image>
		</view>
		<view class="info_list">
			<text class="info_name">地&emsp;&emsp;区</text>
			<text class="info_value">{{buildInfo.area.name}}</text>
			<text class="info_name">楼盘名称</text>
			<text class="info_value">{{buildInfo.style.name}}</text>
			<text class="info_name">户&emsp;&emsp;型</text>
			<text class="info_value">{{buildInfo.model.name}}</text>
		</view>
		<view class="header-content">
			<view class="header-left">
				<view class="line"></view>
				<text class="header-title">地理位置</text>
			</view>
		</view>
		<map style="width: 670rpx; height: 406rpx;" :latitude="buildInfo.latitude" :longitude="buildInfo.longitude"
			:markers="covers" @click.stop="getMap" :show-location="true"></map>
		<view class="header-content">
			<view class="header-left">
				<view class="line"></view>
				<text class="header-title">案例展示</text>
			</view>
		</view>
		<view class="example-list">
			<view class="example-item" @click="openCase">
				<image class="example-item-image" src="../../static/images/mask_home.png"></image>
				<view class="example-item-mark"><text class="example-item-size">30m²</text></view>
			</view>
			<view class="example-item" @click="openCase">
				<image class="example-item-image" src="../../static/images/mask_bookshelf.png"></image>
				<view class="example-item-mark"><text class="example-item-size">80m²</text></view>
			</view>
			<view class="example-item" @click="openCase">
				<image class="example-item-image" src="../../static/images/mask_home.png"></image>
				<view class="example-item-mark"><text class="example-item-size">30m²</text></view>
			</view>
			<view class="example-item" @click="openCase">
				<image class="example-item-image" src="../../static/images/mask_bookshelf.png"></image>
				<view class="example-item-mark"><text class="example-item-size">80m²</text></view>
			</view>
		</view>
		<button class="submit">确定预约</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				buildInfo: {
					area: {},
					style: {},
					model: {}
				},
				id: 0, // 使用 marker点击事件 需要填写id
				title: 'map',
				covers: []

			}
		},
		onLoad() {
			uni.request({
				url: 'https://baiyi.kent.work/api/v1/system/getBuildDetail',
				method: 'post',
				data: {
					"id": 40
				},
				success: res => {
					this.buildInfo = res.data.data.buildInfo
					this.covers = [{
						"latitude": this.buildInfo.latitude,
						"longitude": this.buildInfo.longitude,
						"iconPath": '../../static/images/markers.png',
						"while": 30,
						"height": 30
					}]
				},
				fail: () => {},
				complete: () => {}
			});

		},
		methods: {
			openCase() {
				uni.navigateTo({
					url: '/pages/case/index',
				});
			},
			getMap(){
				uni.openLocation({
					latitude:parseFloat(this.buildInfo.latitude),
					longitude:parseFloat(this.buildInfo.longitude),
					name:this.buildInfo.name,
					success:function(){
						
					},
					fail:function(error){
						console.log(error);
					}
				})
			}
			
		}
	};
</script>

<style>
	page {
		background-color: #f5f5f5;
	}

	.content {
		box-sizing: border-box;
		width: 100vw;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.logo {
		width: 100%;
		height: 450rpx;
	}

	.info_list {
		box-sizing: border-box;
		font-size: 28rpx;
		grid-row-gap: 20rpx;
		padding: 0rpx 40rpx;
		width: 100%;
		display: grid;
		grid-template-columns: 40% 1fr;
	}

	.header-content {
		box-sizing: border-box;
		width: 100%;
		display: flex;
		align-items: center;
		padding: 40rpx 40rpx 26rpx 40rpx;
		justify-content: space-between;
	}

	.header-left {
		display: flex;
		align-items: center;
	}

	.header-title {
		
		color: #333333;
		font-size: 32rpx;
		font-weight: 700;
		margin-left: 20rpx;
	}

	.header-content-share {
		width: 38rpx;
		height: 38rpx;
	}

	.line {
		width: 8rpx;
		height: 30rpx;
		background: #3d9c36;
	}

	.info_name {
		
		color: #333333;
		font-size: 24rpx;
	}

	.info_value {
		
		color: #333333;
		font-size: 24rpx;
		font-weight: bold;
	}

	.example-list {
		box-sizing: border-box;
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-gap: 22rpx;
		padding: 0 40rpx;
		width: 100%;
	}

	.example-item {
		position: relative;
		border-radius: 16rpx;
		box-shadow: 0rpx 4rpx 2rpx rgba(0, 0, 0, 0.1);
	}

	.example-item-image {
		width: 100%;
		height: 200rpx;
	}

	.example-item-mark {
		position: absolute;
		width: 100%;
		height: 50rpx;
		background-color: white;
		bottom: 0;
		border-radius: 0 0 16rpx 16rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.example-item-size {
		font-size: 28rpx;
	}

	.example-item-size::before {
		content: '— ';
		color: #3d9c36;
	}

	.example-item-size::after {
		content: ' —';
		color: #3d9c36;
	}

	.submit {
		box-sizing: border-box;
		height: 80rpx;
		width: 328rpx;
		color: #fff;
		font-size: 32rpx;
		background-color: #3d9c36;
		margin: 80rpx;
	}
</style>